<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
	String product_id = request.getParameter("product_id");
	String warehouse_id = request.getParameter("warehouse_id");
	String gd_id = request.getParameter("gd_id");
%>
<html>
	<head>
		<title>流水明细</title>
	</head>
	<script type="text/javascript">
	$(function(){
		init();
	});
		function init(){
			$("#dbManage").layout();
		
				//右侧分页数据
			$('#table').datagrid({
				title:'库存明细',
				iconCls:'icon-details',
				showFooter:true,
				rownumbers:true,
				nowrap:false,
				url:'<%=contextPath %>/springMVC/warehouse/listPagePurchaseApplyDBLog',
				queryParams:{
					product_id:'<%=product_id%>',
					gd_id:'<%=gd_id%>',
					warehouse_id:'<%=warehouse_id%>'
				},
				loadMsg:'正在加载数据，请稍后......',
				fitColumns:true,
				columns:[[
					{title:'日期',field:'operation_date',width:200,align:'center'},
					{title:'摘要',field:'summary',width:300,align:'center'},
					{title:'数量',field:'num',width:50,align:'center'},
					{title:'经办人',field:'person',width:100,align:'center'},
					{title:'类别',field:'direction',width:50,align:'center',formatter:function(value,row,index){
						if(value == '0'){
							return "入库";
						}
						if(value == '1'){
							return "出库";
						}
					}},
					{title:'业务类型',field:'business_type',hidden:'true'},
					{title:'业务id',field:'business_id',hidden:'true'},
					{title:'查看凭证',field:'detail',width:50,align:'center',formatter:function(value,rowData,rowIndex){
						if(rowData.business_type == '<%=com.beaut.project.util.StaticData.DB_INIT%>'){
							return "";
						}
						if(rowData.business_type == '<%=com.beaut.project.util.StaticData.GD_PRODUCT_IN%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showPurchaseProductIn('"+rowData.business_id+"')\"/>";
						}
						if(rowData.business_type == '<%=com.beaut.project.util.StaticData.GD_PURCHASE_APPLY_USE%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showApplyUse('"+rowData.business_id+"')\"/>";
						}
						if(rowData.business_type == '<%=com.beaut.project.util.StaticData.GD_RETURN_APPLY%>'){
							return "<input type='button'  style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='明细' onclick=\"showReturnMaterial('"+rowData.business_id+"')\"/>";
						}
						return "";
					}}
				]],
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert("提示",rtJson.rtMsrg);
					}
				}
			});
			//----end
}
	function doSearch()
	{	
		var firstDay = $('#start_date').datebox('getValue');
		var endDay = $('#end_date').datebox('getValue');
		$('#table').datagrid('load',{
			gd_id:'<%=gd_id%>',
			product_id:'<%=product_id%>',
			warehouse_id:'<%=warehouse_id%>',
			start_date:firstDay,
			end_date:endDay
			});
	}
		function showPurchaseProductIn(product_in_id){
			openDialogResize('<%=contextPath %>/springViews/warehouse/addOrEditPurchaseProductIn.jsp?isShow=1&product_in_id='+product_in_id,1000, 800);	
		}
		function showApplyUse(apply_use_id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditPurchaseApplyUse.jsp?isShow=1&apply_use_id='+apply_use_id,1000, 800);	
		}
		function showReturnMaterial(id){
			openDialogResize('<%=contextPath %>/springViews/gd/addOrEditPurchaseReturnApply.jsp?isShow=1&return_id='+id,1000, 800);	
		}
	</script>
	<body>
		<div id="dbManage" class="easyui-layout" data-options="fit:true">
		    <div region="center">
		    	    <div id="table"  data-options="fit:true,toolbar:'#tb'"></div>  
		    	    <div id="tb" style="padding:3px;height:auto">
						<div align="right">
							开始日期: <input id="start_date" name="start_date" class="easyui-datebox"/>
							结束日期: <input id="end_date" name="end_date" class="easyui-datebox"/>
							<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();">搜索</a>
						</div>
					</div>
		    </div>
		</div>
	</body>
</html>
